package com.njitweb.mapper;

import com.njitweb.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

//   @Insert("insert into category(name, description, created_at, updated_at)" +
//           "values (#{name},#{description},#{createdDate},#{updatedDate})")
//    void addCategory(Category category);

    @Insert("INSERT INTO category(name, description, created_at, updated_at) " +
            "VALUES (#{name}, #{description}, #{createdDate}, #{updatedDate})")
    void addCategory(Category category);

    @Select("select * from category")
    List<Category> listCategory();

    @Delete("delete  from  category where  id=#{id}")
    void deleteCategory(Integer id);

    @Select("select * from category where id=#{id}")
    Category getDetailCategory(Integer id);

    @Update("update  category set name=#{name},description=#{description} where id=#{id}")
    void updateCategory(Category category);
}
